package net.pulseproject.commons.util;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

public abstract class AbstractUtilTestCase {
	
	@SuppressWarnings("boxing")
	protected final void utilConstructorNotInvocable(final Class<?> clazz) {
		final Constructor<?>[] constructors = clazz.getDeclaredConstructors();
		assertThat(constructors.length, equalTo(1));

		final Constructor<?> constructor = constructors[0];
		assertThat(Modifier.isPrivate(constructor.getModifiers()), equalTo(Boolean.TRUE));
		
		// invoke constructor to satisfy coverage
		constructor.setAccessible(true);
		try {
			constructor.newInstance();
		} catch (final Exception e) {
			throw new RuntimeException("Could not create instance!", e);
		}
	}
}
